9029430f5f78d0abe373c4b2d9cee405530fc481,sonar-core/src/test/java/org/sonar/core/graph/SubGraphTest.java,SubGraphTest,should_check_edge_direction,#,96
Before Change
// a -uses-> b -inherits -> c
// a -uses-> d -implements-> e
Graph sub = SubGraph.extract(a, "uses", Direction.IN /* instead of out */, "implements", Direction.OUT);
assertThat(sub.getVertices()).hasSize(1);
assertThat(sub.getVertex(a.getId())).isNotNull();
After Change
@Test
public void should_check_edge_direction() {
TinkerGraph graph = new TinkerGraph();
Vertex a = GraphHelper.addVertex(graph, null, "key", "a");
Vertex b = GraphHelper.addVertex(graph, null, "key", "b");
Vertex c = GraphHelper.addVertex(graph, null, "key", "c");
Vertex d = GraphHelper.addVertex(graph, null, "key", "d");
Vertex e = GraphHelper.addVertex(graph, null, "key", "e");
Edge ab = GraphHelper.addEdge(graph, null, a, b, "uses");
Edge bc = GraphHelper.addEdge(graph, null, b, c, "inherits");
Edge ad = GraphHelper.addEdge(graph, null, a, d, "uses");
Edge de = GraphHelper.addEdge(graph, null, d, e, "implements");
// a -uses-> b -inherits -> c
// a -uses-> d -implements-> e
Graph sub = SubGraph.extract(a, EdgePath.create(Direction.IN /* instead of out */, "uses", Direction.OUT, "implements"));
assertThat(sub.getVertices()).hasSize(1);
assertThat(sub.getVertex(a.getId())).isNotNull();